<?php
/**
 * 导航model
 */
class Navigation_model extends CT_Model
{
	public $_table = 'admin_menu';
	
	public function __construct()
	{
		parent::__construct();
		$this->load->database();
	}

	//判断 导航名称是否重复
	public  function  check_navigation_name($navigation_name,$navigation_id=NULL)
	{

		if(empty($navigation_id)){
			$this->db->where('name',$navigation_name);
		}else{
			$this->db->where('id <>',$navigation_id);
			$this->db->where('name',$navigation_name);
		}

		$data = $this->db->select('id')->get($this->_table)->row_array();
		return $data['id'];

	}

	//判断导航链接是否重复
	public  function check_link($link,$id=NULL)
	{
		if(empty($id)){
			$this->db->where('link',$link);
		}else{
			$this->db->where('id <>',$id);
			$this->db->where('link',$link);
		}

		$data = $this->db->select('id')->get($this->_table)->row_array();
		return $data['id'];
	}
	
}